package com.example.servicestest

import android.app.Service
import android.content.Intent
import android.os.Binder
import android.os.IBinder
import android.util.Log

class MyService : Service() {
    val TAG  = "MyService"

    private val mBinder = DownloadBinder()

    inner class DownloadBinder : Binder(){

        fun startDownload(){
            Log.d(TAG, "startDownload: executed")
        }

        fun getProgress():Int{
            Log.d(TAG, "getProgress: executed")
            return 0
        }
    }

    override fun onBind(intent: Intent): IBinder {
        return mBinder
    }

    override fun onCreate() {
        Log.d(TAG, "onCreate")
        super.onCreate()
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Log.d(TAG, "onStartCommand")
        return super.onStartCommand(intent, flags, startId)

        //在service内部停止 调用stopSelf()
    }

    override fun onDestroy() {
        Log.d(TAG, "onDestroy")
        super.onDestroy()
    }
}